package com.example.demo.config;

import com.example.demo.api.MatchAPI;
import com.example.demo.api.TestAPI;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;

import javax.servlet.http.HttpServletRequest;

/**
 * @author CY
 * @date 2023/03/23 23:33
 **/
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(new TestAPI(),"/test");
        registry.addHandler(new MatchAPI(),"/findMatch").addInterceptors(new HttpSessionHandshakeInterceptor());

    }
}
